Module talk:Tablebuilder
Obsolete compared to mw.html? What's the difference between this and building tables with mw.html manually? For example, local tbl = mw.html.create( 'table' ) :addClass( 'wikitable' ) :tag( 'tr' ) :tag( 'th' ) :wikitext( 'foo' ) :done() -- and so on... :Well, a couple of things: :* First of all mw.html is a general interface designed to create html elements, but not specifically tables. So it quickly becomes complex if you're creating very big tables. :* Secondly, it quickly becomes very repetitive and inefficient if you're adding a simple table with more than say 2 dozen rows. :* Thirdly, its mw.html is complex for the beginner to understand. For example, it took me a couple of hours to understand its basic functions even though I already understand html and wiki tables. :* Lastly, at worst it can serve as a demo for beginners (non-coders) to understand how it all works. Dessamator (talk) 14:01, March 18, 2015 (UTC) ::I don't understand how you can claim your code is more efficient when you're essentially just wrapping mw.html. I'll agree that the documentation for lua is a little difficult to grasp, but I don't think that's a issue with it's implementation; it's designed to be similar to how you'd build HTML in jQuery. :: I had a quick look, and to be honest I find this probably harder to decipher than mw.html. The documentation you added doesn't seem to help much, and is even a bit confusing ("Appends a column row to a table" - Column or row, what is it?). The code itself can use a little cleanup too ( inconsistent spacing, arbitrary use of semicolons, redundant use of done() etc.). Especially the example. - Tjcool007 (Talk) 10:49, March 21, 2015 (UTC) ::: @cqm : Well, it is meant as a wrapper to reduce the problems with understanding the documentation. Besides it is a good example of how it all works anyway. Also the current error handling for mw.html library is horrible. It doesn't output problems related to the script itself, but rather the mw.html library. Creating a wrapper like this makes it easy to simply add better error handling, and if there's a need for it add an xpcall to it. ::: It also helps to reduce the error handling I have to do on each script/module I create. Rather than repeating this error checking and these functions over many scripts this makes it easier for me, and hopefully others. ::: @ Tjcool007 : Good points (I fixed the indenting, and improved the documentation a bit), it was created as I was migrating from using the plain "wikitext table" to a mw.html based table. That's why the documentation is somewhat lacking and confusing, as this was done while learning about the library. Also that's another reason I added it here, to get some feedback and maybe let others improve on it or simply create better implementations of it. ::: That's at least the one I'm using in my wiki, and so far it helps. ::: P.S. Feel free to to make adjustments to it. ::: Dessamator (talk) 00:15, March 23, 2015 (UTC) ::::The error handling could definitely be improved, if you notice anything specific I'd suggest reporting it in phabricator (mediawiki's bug tracker). If it gets fixed, I'd be happy to backport it to wikia assuming it gets ok'd by staff in the interests of getting wikia's version of lua up to date in terms of behaviour and libraries. :::: :::::: I think wikimedia may have already improved the error handling. It simply hasn't been added to wikia, see https://phabricator.wikimedia.org/rELUA98f25aa9a19fed33140d04e5a60a89effa2a926e here. That's my main concern zbout using this library. The errors it outputs are unhelpful. Especially if you have a lot of code because it doesn't provide a traceback. :::::: This is the kind of uninformative errors it currently outputs: :::::: Lua error in mw.html.lua at line 128: attempt to call method '_build' (a nil value). :::::: Dessamator (talk) 10:37, March 23, 2015 (UTC) TableBuilder v2 A lot of refactoring and rewriting some of the functions, making it easier to create rows and columns and modify them. A similar api structure to Java (hope I don't get sued). Adding methods for simple things such as setting background/text color is also simpler. It creates a two dimensional array/table that is used to populate and add stuff to html table. Dessamator (talk) 18:32, August 5, 2015 (UTC)